#include<iostream>
using namespace std;

const int N = 1000010;

int n, m;
int p[N], s[N];

int l, r;

int main(){
    scanf("%d%d", &n, &m);
    s[0] = 0;
    for(int i = 1; i <= n; i++){
        scanf("%d", &p[i]);
        s[i] = s[i - 1] + p[i];     //读入同时，生成前缀和数组
    }
    for(int i = 0; i < m; i ++){
        scanf("%d%d", &l, &r);
        printf("%d\n", s[r] - s[l - 1]);       //前缀和思想
    }
    return 0;
}